import { useEffect } from 'react';
import http from '@/services/request';
import { useState } from 'react';
export const Axiosrepo = () => {
  const [dataSource, setDataSource]: any = useState([]);
  const [repolist, setRepoList] = useState([]);
  useEffect(() => {
    http.get(`/server/repositoryInfoSlaughter/list/1/10`).then((res) => {
      setRepoList(res.data.records);
    });
  }, []);
  return {
    setDataSource,
    dataSource,
    repolist
  };
};
/* // 选择器配置
export const SearchSelector = (props: any) => {

  const [searchid, setsearchid]: any = useState()
  return <div style={{ display: 'inline-block', width: '380px', marginBottom: 10, marginRight: 10 }}>
    <Select defaultValue={Options[0].label} style={{ width: 100 }}
      defaultActiveFirstOption
      onSelect={(value: string, option: any) => {
        setsearchid(option.key)
      }}
    >
      {Options.map(i =>
        (<Option value={i.label} key={i.value} children={null}></Option>))}
    </Select>
    <Search
      placeholder="请输入您要查的数据"
      onSearch={(e: string) => {
        // 清空输入框之后，再次搜索，出现的是初始化时候的数据
        if (e === '') {
          http.get('/server/adoptionSlaughter/list/1/10').then((res: { data: { records: any } }) => {
            props.dataSource(res.data.records)
          })
          return
        }
        switch (searchid) {
          case 'materialName': {
            http(`/server/adoptionSlaughter/fuzzyGetMaterialName/${e}`).then((res: { data: any }) => {
              props.dataSource(res.data)
            })
            break
          }
          case 'recipient': {
            http(`/server/adoptionSlaughter/fuzzyGetRecipient/${e}`).then((res: { data: any }) => {
              props.dataSource(res.data)
            })
            break
          }
          case 'repoName': {
            http(`/server/adoptionSlaughter/fuzzyGetRepoName/${e}`).then((res: { data: any }) => {
              props.dataSource(res.data)
            })
            break
          }
          case 'specification': {
            http(`/server/adoptionSlaughter/fuzzyGetSpecification/${e}`).then((res: { data: any }) => {

              props.dataSource(res.data)
            })
            break
          }
          default: {
            break
          }
        }
      }}
      style={{ width: '280px' }}
      enterButton
    />
  </div>
}
const Options = [
  { label: '材料名称', value: 'materialName', onClick: (e: any) => { } },
]
const menu = (
  <Menu
    items={[
      {
        key: 0,
        label: <span>详情</span>
      },
      {
        key: 1,
        label: <span>复制</span>
      }, {
        key: 2,
        label: <Button onClick={function () { window.print() }}>打印</Button>
      }
    ]}

  />
)



// 按钮组
export const buttonGroup: IToolButton[] = [
  { type: 'create', text: '新增批次', isShow: true, onClick: () => { } },
  { type: 'delete', text: '批量删除', isShow: true, onClick: () => { } },
  { type: 'import', text: '导入', isShow: true, onClick: () => { } },
  { type: 'export', text: '导出', isShow: true, onClick: () => { } },

]


//table的表格头
export const FormColumns: any = [
  {
    title: '仓库id',
    dataIndex: 'repoId',
    key: 'repoId',
    width: 180
  },
  {
    title: '用户id',
    dataIndex: 'userId',
    key: 'userId',
    width: 130
  },
  {
    title: '生产批号',
    dataIndex: 'batchNumber',
    key: 'batchNumber',
    width: 180
  },
  {
    title: '产品名称',
    dataIndex: 'productName',
    key: 'productName',
    width: 100
  },
  {
    title: '材料名称',
    dataIndex: 'matName',
    key: 'matName',
    width: 100
  },
  {
    title: '供应商',
    dataIndex: 'supplier',
    key: 'supplier',
    width: 150
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    width: 100
  },
  {
    title: '件数（/件）',
    dataIndex: 'cases',
    key: 'cases',
    width: 130
  },
  {
    title: '只数（/只）',
    dataIndex: 'quantity',
    key: 'quantity',
    width: 130
  },
  {
    title: '重量(kg)',
    dataIndex: 'weight',
    key: 'weight',
    sorter: (a: any, b: any) => a.num - b.num,
    width: 130
  },
  {
    title: '规格（/箱）',
    dataIndex: 'specification',
    key: 'specification',
    sorter: (a: any, b: any) => a.num - b.num,
    width: 130
  },
  {
    title: '单价(元)',
    dataIndex: 'money',
    key: 'money',
    sorter: (a: any, b: any) => a.price - b.price,
    width: 100
  },
  {
    title: '收货商',
    dataIndex: 'supplier',
    key: 'supplier',
    sorter: (a: any, b: any) => a.price - b.price,
    width: 100
  },
  {
    title: '单位',
    dataIndex: 'unit',
    key: 'unit',
    sorter: (a: any, b: any) => a.price - b.price,
    width: 150
  },
  {
    title: '出库时间',
    dataIndex: 'date',
    key: 'date',
    sorter: (a: any, b: any) => a.price - b.price,
    width: 120
  },
  {
    title: '创建时间',
    dataIndex: 'gmtCreate',
    key: 'gmtCreate',
    sorter: (a: any, b: any) => a.price - b.price,
    width: 120
  },
  {
    title: '更新时间',
    dataIndex: 'gmtModified',
    key: 'gmtModified',
    sorter: (a: any, b: any) => a.price - b.price,
    width: 120
  },
  {
    title: '备注',
    dataIndex: 'remark',
    key: 'remark',
    width: 100
  },
  {
    title: '操作',
    dataIndex: 'action',
    key: 'action',
    width: 150,
    render: (_: any, record: { key: React.Key }) => (
      <Space>
        <a>编辑</a>
        <Popconfirm
          title="确定删除?"
          okText="确认"
          cancelText="取消"
          // cancelButtonProps={{ size: 'middle' }}
          onConfirm={() => {}}
        >
          <a style={{ color: '#ff4d4f' }}>删除</a>
        </Popconfirm>
        <Dropdown overlay={menu}>
          <a onClick={(e) => e.preventDefault()}>···</a>
        </Dropdown>
      </Space>
    ),
    fixed: 'right'
  }
] */
//复选框的接口
export interface DataType {
  id: number;
  name: string;
  age: number;
  address: string;
}
